<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>加载条动画</title>
    <style>
      .loading43 {
        width: 140px;
        height: 4px;
        border-radius: 2px;
        background-color: rgba(0, 0, 0, 0.2);
        position: relative;
      }

      .loading43:after {
        content: "";
        height: 4px;
        border-radius: 2px;
        background-color: #2aa738;
        position: absolute; /*这里不设置top、left属性，默认值就可以*/
        animation: eff43 2.4s ease-in-out infinite;
      }

      @keyframes eff43 {
        0% {
          width: 0;
        }
        50% {
          width: 100%;
        }
        100% {
          width: 0;
          right: 0; /*设置right值为0，使伪元素宽度变成0时，是从左往右变化*/
        }
      }
    </style>
  </head>
  <body>
    <div class="loading43"></div>
  </body>
</html>
